/*
Zeke Elder - zbe@andrew.cmu.edu
Amal Chemmany - achemman@andrew.cmu.edu
Nishant Kumar - nkumar1@andrew.cmu.edu
15-637
4/2/2012
 */

function addRow() {
       var count = document.getElementById("count");
       if (count.value <= 10) {
               var elemId = "div" + count.value;
               var elem = document.getElementById(elemId);
               elem.setAttribute("class", "visibleDiv");
               count.value++;
       }
}

function manageList(searchElement) {
	search = searchElement.value;
	search = search.replace("/^\s+|\s+$/g", '');
	var listOfUsersShow = document.getElementsByClassName("userentryshow");
	for ( var i = 0; i < listOfUsersShow.length && i >= 0; i++) {
		if (!listOfUsersShow[i].id.match(search)) {
			listOfUsersShow[i].setAttribute("class", "userentrynoshow");
				i--;
		} 
	}
	var listOfUsersNoShow = document.getElementsByClassName("userentrynoshow");
	for ( var i = 0; i < listOfUsersNoShow.length && i >= 0; i++) {
		if (listOfUsersNoShow[i].id.match(search) || search=='') {
			listOfUsersNoShow[i].setAttribute("class", "userentryshow");
				i--;
		} 
	}
}

function displayblock() {
	myDiv = document.getElementById("register_div");
	if (myDiv.getAttribute("class") == "hiddenDiv") {
		myDiv.setAttribute("class", "visibleDiv");
	} else {
		myDiv.setAttribute("class", "hiddenDiv");
	}
}

function displaythislogin(id) {
	openidDiv = document.getElementById("loginbox_openid");
	fithubDiv = document.getElementById("loginbox_fit");

	openidDiv.setAttribute("class", "hiddenDiv");
	fithubDiv.setAttribute("class", "hiddenDiv");

	document.getElementById(id).setAttribute("class", "visibleDiv");

}

function get(name) {
	if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)'))
			.exec(location.search))
		return decodeURIComponent(name[1]);
}